{% extends "analysis_plugins/general_information.html" %}

{% block analysis_result_details %}

    </table>
    <table class="table table-bordered">
        <colgroup>
            <col style="width: 50px">
            <col style="width: 150px">
            <col style="width: 600px">
        </colgroup>
        <tbody class="table-analysis">
            {% for match_dict in analysis_result["matches"] %}
                <tr>
                    {% set row_count = 3 + (1 if match_dict.meta.date else 0) + (1 if match_dict.meta.author else 0) %}
                    <td class="table-head-light" rowspan={{ row_count }}>{{ loop.index - 1 }}</td>
                    <td class="table-head-light">Matched Rule</td>
                    <td class="table-head-light">{{ match_dict['rule'] }} </td>
                </tr>
                <tr>
                    <td> Description</td>
                    <td> {{ match_dict['meta']['description'] }} </td>
                </tr>
                {% if match_dict.meta.date %}
                    <tr>
                        <td>Rule Version</td>
                        <td>{{ match_dict['meta']['date'] }}</td>
                    </tr>
                {% endif %}
                {% if match_dict.meta.author %}
                    <tr>
                        <td>Rule Author</td>
                        <td><a href="https://github.com/Yara-Rules/rules/blob/master/crypto/crypto_signatures.yar">
                            {{ match_dict['meta']['author'] }}
                        </a></td>
                    </tr>
                {% endif %}
                <tr>
                    <td>Matches</td>
                    <td class="p-0 m-0">
                        <table class="table table-bordered" style="margin:0;">
                            <colgroup>
                                <col style="width: 75px">
                                <col style="width: 525px">
                            </colgroup>
                            <tr>
                                <td class="table-head-light">offset</td>
                                <td class="table-head-light">name</td>
                                <td class="table-head-light" style="width: 30%;">value</td>
                                <td class="table-head-light" style="width: 60%;">value hex</td>
                            </tr>
                            {% for offset, name, matched_string in match_dict['strings'] %}
                                <tr>
                                    <td> 0x{{ '0%x' % offset }} </td>
                                    <td> {{ name[1:] }} </td>
                                    <td> {{ matched_string }} </td>
                                    <td style="font-family: monospace;"> {{ matched_string | str_to_hex }} </td>
                                </tr>
                            {% endfor %}
                        </table>
                    </td>
                </tr>
            {% endfor %}
        </tbody>
{% endblock %}
